#ifndef _UTILS_SURFACE_H_
# define _UTILS_SURFACE_H_

# include "config.h"
# include "Utils\\Rect.h"
# include <SDL/SDL.h>

NS_BEGIN(SDL)
	NS_BEGIN(UTILS)

	class Surface
	{
	private:
		SDL_Surface* m_surface;
		bool m_dontFree;

	public:
		Surface(SDL_Surface* _surface = NULL, bool _dontFree = false);
		Surface(Surface const& _surface);
		~Surface();

		Surface& operator=(Surface const& _surface);
		bool operator==(Surface const& _surface) const;
		bool operator!=(Surface const& _surface) const;

		static int BlitSurface(SDL_Surface* _src, Rect const* _srcRect,
							   SDL_Surface* _dst, Rect const* _dstRect);
		static SDL_Surface* DuplicateSurface(SDL_Surface* _src);
		static int SetColorKey(SDL_Surface* _surface, Uint32 _colorkey);
		static int SetAlpha(SDL_Surface* _surface, Uint8 _alpha);
		static Uint32 GetPixel(SDL_Surface* _surface, Uint32 _x, Uint32 _y);
		static void SetPixel(SDL_Surface* _surface, Uint32 _pixel,
							 Uint32 _x, Uint32 _y);
		int BlitSurface(Rect const* _srcRect, SDL_Surface* _screen,
						Rect const* _dstRect);
		SDL_Surface* DuplicateSurface() const;
		int SetColorKey(Uint32 _colorkey);
		int SetAlpha(Uint8 _alpha);
		Uint32 GetPixel(Uint32 _x, Uint32 _y) const;
		void SetPixel(Uint32 _pixel, Uint32 _x, Uint32 _y);

		SDL_Surface* GetSurface();
		void SetSurface(SDL_Surface* _surface);
		SDL_PixelFormat* GetPixelFormat();
		int GetW() const;
		int GetH() const;
		bool GetDontFree() const;
		void SetDontFree(bool _value);

	public:
		__declspec(property(get=GetSurface, put=SetSurface)) SDL_Surface* surface;
		__declspec(property(get=GetPixelFormat)) SDL_PixelFormat* pixelFormat;
		__declspec(property(get=GetW, put=SetW)) int w;
		__declspec(property(get=GetH, put=SetH)) int h;
	};

	NS_END(UTILS)
NS_END(SDL)

#endif // _UTILS_SURFACE